package com.lewa.os.ui;

import android.app.Activity;
import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.support.lewa.view.LewaPagerView;
import android.support.lewa.view.PagerAdapter;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import java.util.ArrayList;

public class ViewPagerIndicatorActivity extends Activity
  implements ActivityResultBridge
{
  private int ScreenDisertyDpi = 0;
  private int currentScreen = 0;
  private ArrayList<StartParameter> flingViewClass;
  private ArrayList<PendingContentLoader> mContentLoaders;
  private ViewPagerIndicator mIndicator;
  private int mIndicatorResId;
  private int mLayoutResId;
  private LoadPendingContentHandler mLoadContentHandler;
  LocalActivityManager mLocalActivityManager;
  private MPagerAdapter mPagerAdapter;
  private int mPagerResId;
  private ActivityResultBridge.ActivityResultReceiver mResultReceiver;
  private LewaPagerView mViewPager;
  private int pagernums;

  private View activityToView(Intent paramIntent)
  {
    Activity localActivity;
    Window localWindow = this.mLocalActivityManager.startActivity(String.valueOf(paramIntent.getFlags()), paramIntent);
    if (localWindow != null);
    for (View localView = localWindow.getDecorView(); ; localView = null)
    {
      if (localView != null)
      {
        localView.setVisibility(0);
        localView.setFocusableInTouchMode(true);
        ((ViewGroup)localView).setDescendantFocusability(262144);
        int i = paramIntent.getFlags();
        localActivity = getItemActivity(i);
        if (localActivity != null)
        {
          if (localActivity instanceof ActivityResultBridge.ActivityResultReceiver)
            ((ActivityResultBridge.ActivityResultReceiver)localActivity).registerActivityResultBridge(this);
          if (localActivity instanceof PendingContentLoader)
          {
            if (this.mContentLoaders == null)
              this.mContentLoaders = new ArrayList();
            if (i != this.currentScreen)
              break;
            this.mContentLoaders.add(0, (PendingContentLoader)localActivity);
          }
        }
      }
      return localView;
    }
    this.mContentLoaders.add((PendingContentLoader)localActivity);
    return localView;
  }

  public int getCurrentPage(int paramInt)
  {
    return this.mViewPager.getCurrentItem();
  }

  public Activity getItemActivity(int paramInt)
  {
    return this.mLocalActivityManager.getActivity(String.valueOf(paramInt));
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    if (this.mResultReceiver == null)
      return;
    for (int i = 0; i < this.flingViewClass.size(); ++i)
    {
      Activity localActivity = getItemActivity(i);
      if ((localActivity == null) || (!(localActivity instanceof ActivityResultBridge.ActivityResultReceiver)))
        continue;
      ((ActivityResultBridge.ActivityResultReceiver)localActivity).handleActivityResult(this.mResultReceiver, paramInt1, paramInt2, paramIntent);
    }
    this.mResultReceiver = null;
  }

  public void onConfigurationChanged(Configuration paramConfiguration)
  {
    super.onConfigurationChanged(paramConfiguration);
    if (2 == paramConfiguration.orientation)
      this.mIndicator.init(this.currentScreen, this.mPagerAdapter.getCount(), this.mPagerAdapter, this.ScreenDisertyDpi, 1);
    do
      return;
    while (1 != paramConfiguration.orientation);
    this.mIndicator.init(this.currentScreen, this.mPagerAdapter.getCount(), this.mPagerAdapter, this.ScreenDisertyDpi, 0);
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(this.mLayoutResId);
    this.mLocalActivityManager = new LocalActivityManager(this, true);
    this.mLocalActivityManager.dispatchCreate(paramBundle);
    this.mLocalActivityManager.dispatchResume();
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    this.ScreenDisertyDpi = localDisplayMetrics.densityDpi;
    this.mViewPager = ((LewaPagerView)findViewById(this.mPagerResId));
    this.mPagerAdapter = new MPagerAdapter(this, this.mViewPager);
    this.mIndicator = ((ViewPagerIndicator)findViewById(this.mIndicatorResId));
    this.mViewPager.setOnPageChangeListener(this.mIndicator);
    for (int i = 0; i < this.pagernums; ++i)
    {
      StartParameter localStartParameter = (StartParameter)this.flingViewClass.get(i);
      Intent localIntent = new Intent(this, localStartParameter.mCls);
      if (localStartParameter.mIntent != null)
      {
        localIntent.setAction(localStartParameter.mIntent.getAction());
        localIntent.putExtras(localStartParameter.mIntent);
        localIntent.setData(localStartParameter.mIntent.getData());
      }
      localIntent.setFlags(i);
      View localView = activityToView(localIntent);
      localView.setId(1);
      this.mPagerAdapter.addPage(localStartParameter.mCls, null, localStartParameter.mIndicatorResId, localView);
    }
    this.mViewPager.setAdapter(this.mPagerAdapter);
    this.mViewPager.setCurrentItem(this.currentScreen);
    if (2 == getResources().getConfiguration().orientation)
      this.mIndicator.init(this.currentScreen, this.mPagerAdapter.getCount(), this.mPagerAdapter, this.ScreenDisertyDpi, 1);
    while (true)
    {
      this.mIndicator.setFocusedTextColor(new int[] { 255, 0, 0 });
      this.mIndicator.setOnClickListener(new OnIndicatorClickListener());
      if (this.mContentLoaders != null)
      {
        this.mLoadContentHandler = new LoadPendingContentHandler(null);
        Message localMessage = this.mLoadContentHandler.obtainMessage();
        this.mLoadContentHandler.sendMessageDelayed(localMessage, 100L);
      }
      return;
      this.mIndicator.init(this.currentScreen, this.mPagerAdapter.getCount(), this.mPagerAdapter, this.ScreenDisertyDpi, 0);
    }
  }

  protected void onDestroy()
  {
    super.onDestroy();
    this.mLocalActivityManager.dispatchDestroy(isFinishing());
    this.mPagerAdapter.mPages.clear();
    MPagerAdapter.access$502(this.mPagerAdapter, null);
  }

  protected void onPause()
  {
    super.onPause();
    this.mLocalActivityManager.dispatchPause(isFinishing());
  }

  protected void onResume()
  {
    super.onResume();
    this.mLocalActivityManager.dispatchResume();
  }

  public void setDisplayScreen(int paramInt)
  {
    this.currentScreen = paramInt;
    if (this.mViewPager != null)
    {
      this.mViewPager.setCurrentItem(paramInt);
      if (2 != getResources().getConfiguration().orientation)
        break label62;
      this.mIndicator.init(this.currentScreen, this.mPagerAdapter.getCount(), this.mPagerAdapter, this.ScreenDisertyDpi, 1);
    }
    return;
    label62: this.mIndicator.init(this.currentScreen, this.mPagerAdapter.getCount(), this.mPagerAdapter, this.ScreenDisertyDpi, 0);
  }

  public void setOnTriggerPagerChange(ViewPagerIndicator.OnPagerSlidingListener paramOnPagerSlidingListener)
  {
    this.mIndicator.setOnTriggerListener(paramOnPagerSlidingListener);
  }

  public void setupFlingParm(ArrayList<StartParameter> paramArrayList, int paramInt1, int paramInt2, int paramInt3)
  {
    this.flingViewClass = paramArrayList;
    this.pagernums = paramArrayList.size();
    this.mLayoutResId = paramInt1;
    this.mIndicatorResId = paramInt2;
    this.mPagerResId = paramInt3;
  }

  public void startActivityForResult(ActivityResultBridge.ActivityResultReceiver paramActivityResultReceiver, Intent paramIntent, int paramInt)
  {
    this.mResultReceiver = paramActivityResultReceiver;
    startActivityForResult(paramIntent, paramInt);
  }

  private class LoadPendingContentHandler extends Handler
  {
    public void handleMessage(Message paramMessage)
    {
      if (ViewPagerIndicatorActivity.this.mContentLoaders != null)
      {
        int i = ViewPagerIndicatorActivity.this.mContentLoaders.size();
        if (i > 0)
        {
          ((PendingContentLoader)ViewPagerIndicatorActivity.this.mContentLoaders.get(0)).loadContent();
          ViewPagerIndicatorActivity.this.mContentLoaders.remove(0);
          if (1 != i)
            break label71;
          ViewPagerIndicatorActivity.access$1102(ViewPagerIndicatorActivity.this, null);
        }
      }
      return;
      label71: sendMessageDelayed(obtainMessage(), 500L);
    }
  }

  class MPagerAdapter extends PagerAdapter
    implements ViewPagerIndicator.PageInfoProvider
  {
    private ViewPagerIndicatorActivity.PageInfo info;
    private final Context mContext;
    private final LewaPagerView mPager;
    private final ArrayList<ViewPagerIndicatorActivity.PageInfo> mPages = new ArrayList();

    public MPagerAdapter(Context paramContext, LewaPagerView paramLewaPagerView)
    {
      this.mPager = paramLewaPagerView;
      this.mContext = paramContext;
    }

    public void addPage(Class<?> paramClass, Bundle paramBundle, int paramInt, View paramView)
    {
      addPage(paramClass, null, this.mContext.getResources().getString(paramInt), paramView);
    }

    public void addPage(Class<?> paramClass, Bundle paramBundle, String paramString, View paramView)
    {
      this.info = new ViewPagerIndicatorActivity.PageInfo(paramClass, paramString, paramView);
      this.mPages.add(this.info);
      notifyDataSetChanged();
    }

    public void addPage(Class<?> paramClass, String paramString, View paramView)
    {
      addPage(paramClass, null, paramString, paramView);
    }

    public void destroyItem(View paramView, int paramInt, Object paramObject)
    {
      ((LewaPagerView)paramView).removeView(ViewPagerIndicatorActivity.PageInfo.access$1000((ViewPagerIndicatorActivity.PageInfo)this.mPages.get(paramInt)));
    }

    public void finishUpdate(View paramView)
    {
    }

    public int getCount()
    {
      return this.mPages.size();
    }

    public String getTitle(int paramInt)
    {
      return ViewPagerIndicatorActivity.PageInfo.access$900((ViewPagerIndicatorActivity.PageInfo)this.mPages.get(paramInt));
    }

    public Object instantiateItem(View paramView, int paramInt)
    {
      View localView1 = ViewPagerIndicatorActivity.PageInfo.access$1000((ViewPagerIndicatorActivity.PageInfo)this.mPages.get(paramInt));
      View localView2 = null;
      if (localView1 != null)
      {
        localView2 = ViewPagerIndicatorActivity.PageInfo.access$1000((ViewPagerIndicatorActivity.PageInfo)this.mPages.get(paramInt));
        ((LewaPagerView)paramView).addView(ViewPagerIndicatorActivity.PageInfo.access$1000((ViewPagerIndicatorActivity.PageInfo)this.mPages.get(paramInt)), 0);
      }
      return localView2;
    }

    public boolean isViewFromObject(View paramView, Object paramObject)
    {
      return (paramView == paramObject);
    }

    public void restoreState(Parcelable paramParcelable, ClassLoader paramClassLoader)
    {
    }

    public Parcelable saveState()
    {
      return null;
    }

    public void startUpdate(View paramView)
    {
    }
  }

  class OnIndicatorClickListener
    implements ViewPagerIndicator.OnClickListener
  {
    public void onCurrentClicked(View paramView)
    {
    }

    public void onNextClicked(View paramView)
    {
      ViewPagerIndicatorActivity.this.mViewPager.setCurrentItem(Math.min(-1 + ViewPagerIndicatorActivity.this.mPagerAdapter.getCount(), 1 + ViewPagerIndicatorActivity.this.mIndicator.getCurrentPosition()));
    }

    public void onPreviousClicked(View paramView)
    {
      ViewPagerIndicatorActivity.this.mViewPager.setCurrentItem(Math.max(0, -1 + ViewPagerIndicatorActivity.this.mIndicator.getCurrentPosition()));
    }
  }

  static final class PageInfo
  {
    private final String args;
    private final Class<?> clss;
    private final View mView;

    PageInfo(Class<?> paramClass, String paramString, View paramView)
    {
      this.clss = paramClass;
      this.args = paramString;
      this.mView = paramView;
    }
  }

  public final class StartParameter
  {
    private Class<?> mCls;
    private int mIndicatorResId;
    private Intent mIntent;

    public StartParameter(Intent paramIntent, int paramInt)
    {
      this.mCls = paramIntent;
      this.mIntent = paramInt;
      this.mIndicatorResId = i;
    }
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     com.lewa.os.ui.ViewPagerIndicatorActivity
 * JD-Core Version:    0.5.2
 */